]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add indicator for location service being used
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 28 Jan 2014 17:41:26 +0000 (17:41 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 28 Jan 2014 18:39:12 +0000 (18:39 +0000)
If an application is accessing location through geoclue, show an
indicator in the panel for that so that user knows.

https://bugzilla.gnome.org/show_bug.cgi?id=709372

js/js-resources.gresource.xml
js/ui/panel.js
js/ui/status/location.js [new file with mode: 0644]

index 036970885b9df7ef261c21d54d640ac0f2b66055..6d9d58529760a767134564d32f8b8656a1272cfb 100644 (file)
 
     <file>ui/status/accessibility.js</file>
     <file>ui/status/brightness.js</file>
+    <file>ui/status/location.js</file>
     <file>ui/status/keyboard.js</file>
     <file>ui/status/network.js</file>
     <file>ui/status/power.js</file>
index 5ffd7b91963827c38b27f8e83cdb37e76c6089df..a54555205af60916964a168c03551457497c1a94 100644 (file)
@@ -825,8 +825,10 @@ const AggregateMenu = new Lang.Class({
         this._brightness = new imports.ui.status.brightness.Indicator();
         this._system = new imports.ui.status.system.Indicator();
         this._screencast = new imports.ui.status.screencast.Indicator();
+        this._location = new imports.ui.status.location.Indicator();
 
         this._indicators.add_child(this._screencast.indicators);
+        this._indicators.add_child(this._location.indicators);
         this._indicators.add_child(this._network.indicators);
         if (this._bluetooth) {
             this._indicators.add_child(this._bluetooth.indicators);
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
new file mode 100644 (file)
index 0000000..4a46014
--- /dev/null
@@ -0,0 +1,58 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+
+const PanelMenu = imports.ui.panelMenu;
+
+var GeoclueIface = '<node> \
+  <interface name="org.freedesktop.GeoClue2.Manager"> \
+    <property name="InUse" type="b" access="read"/> \
+  </interface> \
+</node>';
+
+const GeoclueManager = Gio.DBusProxy.makeProxyWrapper(GeoclueIface);
+
+const Indicator = new Lang.Class({
+    Name: 'LocationIndicator',
+    Extends: PanelMenu.SystemIndicator,
+
+    _init: function() {
+        this.parent();
+
+        this._indicator = this._addIndicator();
+        this._indicator.icon_name = 'find-location-symbolic';
+        this._sync();
+
+        this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,
+                                           'org.freedesktop.GeoClue2',
+                                           0,
+                                           Lang.bind(this, this._onGeoclueAppeared),
+                                           Lang.bind(this, this._onGeoclueVanished));
+    },
+
+    _sync: function() {
+        if (this._proxy == null) {
+            this._indicator.visible = false;
+            return;
+        }
+
+        this._indicator.visible = this._proxy.InUse;
+    },
+
+    _onGeoclueAppeared: function() {
+        // FIXME: This should be done async
+        this._proxy = new GeoclueManager(Gio.DBus.system,
+                                         'org.freedesktop.GeoClue2',
+                                         '/org/freedesktop/GeoClue2/Manager');
+        this._proxy.connect('g-properties-changed', Lang.bind(this, this._sync));
+
+        this._sync();
+    },
+
+    _onGeoclueVanished: function() {
+        this._proxy = null;
+
+        this._sync();
+    }
+});